<template>
	<div class="article_detail_wrapper">
		<div class="head">
			<h1>{{ articleData.title }}</h1>
			<p>
				<span>作者：{{ articleData.author }}</span>
				<!-- <span>编辑：振华</span> -->
				<span>发布时间：{{ articleData.pubDate }}</span>
				<span>浏览次数：{{ articleData.clickCount }}</span>
			</p>
		</div>
		<div class="cont" v-html="articleData.content"></div>
		<div class="attrs" v-if="!!articleData.fileList && articleData.fileList.length > 0">
			<h2>附件：</h2>
			<div class="item" v-for="(item, index) in articleData.fileList" :key="index">
				<h4>{{ item.oldName }}</h4>
				<el-button size="medium" type="text" icon="el-icon-download" @click="handleDownloadAttach(item)">下载</el-button>
			</div>
		</div>
	</div>
</template>

<script>
import { mapActions } from 'vuex';
import { downloadAttach } from '@/api/global';
export default {
	data() {
		return {
			articleData: {}
		};
	},
	computed: {
		articleId() {
			return this.$route.params.id;
		}
	},
	mounted() {
		this.getArticleDetail();
	},
	methods: {
		...mapActions(['getNewsDetail']),
		//获取文章详情
		getArticleDetail() {
			this.getNewsDetail(this.articleId).then((res) => {
				console.log(res);
				this.articleData = { ...res };
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.article_detail_wrapper {
	padding-bottom: 64px;
	.head {
		text-align: center;
		h1 {
			font-size: 24px;
			line-height: 1.5;
		}
		p {
			padding: 10px 0;
			margin-top: 10px;
			color: rgba(0, 0, 0, 0.4);
			span {
				margin: 0 20px;
			}
		}
	}
	.cont {
		font-size: 18px;
		padding: 20px 0;
		color: #666;
		line-height: 2;
		p {
			margin-bottom: 2em;
		}
		img {
			display: block;
			max-width: 100%;
		}
	}
	.attrs {
		margin-top: 20px;
		padding-top: 20px;
		border-top: solid 1px #e4e7ed;
		h2 {
			font-size: 16px;
			margin-bottom: 10px;
		}
		.item {
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
		h4 {
			font-weight: normal;
		}
	}
}
</style>
